import { NgModule, SkipSelf, Optional } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PaginationModule } from 'ngx-bootstrap/pagination';
import { RouterModule } from '@angular/router';
import { PaginationComponent } from './pagination/pagination.component';
import { TreeComponent } from './tree/tree.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { SelectComponent } from './select/select.component';
import { PromptComponent } from './prompt/prompt.component';
import { LastStrPipe } from './pipe/last-str.pipe';
import { FirStrPipe, FirStrTPipe } from './pipe/fir-str.pipe';
import { KeysPipe } from './pipe/keys.pipe';
import { SafeStrPipe } from './pipe/safe-str.pipe';
import { PromptService } from './prompt/prompt.service';
import { LocalStorageService } from './serve/local-storage/local-storage.service';
import { CuttingStrPipe } from './pipe/cutting-str.pipe';
import { BreadcrumbComponent } from './breadcrumb/breadcrumb.component';
import { TableComponent } from 'app/public/components/table/table.component';
import { RichEditorDirective } from './directives/rich-editor.directive';
import { InputToIntDirective } from './directives/input-to-int.directive';
import { StepComponent } from './components/step/step.component';
import { ResourceClassifyTreeComponent } from './components/resource-classify-tree/resource-classify-tree.component';
import { ProductTerminalComponent } from './components/product-terminal/product-terminal.component';
import { TreeModule } from 'primeng/primeng';
import { ProductUploadImageComponent } from './components/product-upload-image/product-upload-image.component';
import { FileUploadModule } from 'primeng/primeng';
import { FormControlComponent } from './components/form-control/form-control.component';
import { BsDatepickerModule, BsModalService,ModalModule, TabsModule  } from 'ngx-bootstrap';
import { InputTrimModule } from 'ng2-trim-directive';
import { CustomFormsModule } from 'ng2-validation';
import { ProductTerminalDetailComponent } from './components/product-terminal-detail/product-terminal-detail.component';
import { ResourceClassifyTreeWithDataComponent } from './components/resource-classify-tree-with-data/resource-classify-tree-with-data.component';
import { ProductDetailFormItemComponent } from './components/product-detail-form-item/product-detail-form-item.component';
import { ProductDetailImageComponent } from './components/product-detail-image/product-detail-image.component';
import { ProductDetailFormComponent } from './components/product-detail-form/product-detail-form.component';
// import { ClipboardModule } from 'ngx-clipboard';
import { ResourceTypeListComponent } from './components/resource-type-list/resource-type-list.component';
import { ZsModalComponent } from './components/zs-modal/zs-modal.component';
import { SelectionComponent } from './selection/selection.component';
import { PaginationService } from './pagination/pagination.service';
import { GatewayPavmenuTreeComponent } from './components/gateway-pavmenu-tree/gateway-pavmenu-tree.component';
import { GatewayPavmenuTreeWithDataComponent } from './components/gateway-pavmenu-tree-with-data/gateway-pavmenu-tree-with-data.component';
import { BaseTreeComponent } from './components/base-tree/base-tree.component';
import { FormControlEditComponent } from './components/form-control-edit/form-control-edit.component';
import { DragulaModule } from 'ng2-dragula';
import { BaseRightComponent } from './components/base-right/base-right.component';
import { BaseComponent } from './components/base/base.component';
import { TypeaheadModule } from 'ngx-bootstrap';
import { OrderJoinModalContentComponent } from './components/order-join-modal-content/order-join-modal-content.component';
import {MatButtonModule} from '@angular/material';
import {ConfigService} from './common/config';
import {arrayToStrPipe} from './pipe/arr-to-str.pipe';
// import { UEditorModule } from 'ngx-ueditor';

@NgModule({
  imports: [
    CommonModule,
    RouterModule,
    FormsModule,
    PaginationModule.forRoot(),
    TreeModule,
    ReactiveFormsModule,
    BsDatepickerModule.forRoot(),
    InputTrimModule,
    CustomFormsModule,
    MatButtonModule,
    ModalModule,
    DragulaModule,
    TabsModule.forRoot(),
    TypeaheadModule.forRoot(),
    // UEditorModule.forRoot({
      // **注：** 建议使用本地路径；以下为了减少 ng-alain 脚手架的包体大小引用了CDN，可能会有部分功能受影响
      // 指定ueditor.js路径目录
      // path: '//apps.bdimg.com/libs/ueditor/1.4.3.1/',
      // 默认全局配置项
  //     options: {
  //         themePath: '//apps.bdimg.com/libs/ueditor/1.4.3.1/themes/'
  //     }
  // }), 
  ],
  declarations: [
    TreeComponent,
    PaginationComponent,
    SelectComponent,
    PromptComponent,
    LastStrPipe,
    FirStrPipe,
    FirStrTPipe,
    CuttingStrPipe,
    KeysPipe,
    SafeStrPipe,
    arrayToStrPipe,
    BreadcrumbComponent,
    TableComponent,
    RichEditorDirective,
    InputToIntDirective,
    StepComponent,
    ResourceClassifyTreeComponent,
    ProductTerminalComponent,
    ProductUploadImageComponent,
    FormControlComponent,
    ProductTerminalDetailComponent,
    ResourceClassifyTreeWithDataComponent,
    ProductDetailFormItemComponent,
    ProductDetailImageComponent,
    ProductDetailFormComponent,
    ResourceTypeListComponent,
    ZsModalComponent,
    SelectionComponent,
    GatewayPavmenuTreeComponent,
    BaseRightComponent,
    BaseComponent,
    GatewayPavmenuTreeWithDataComponent,
    BaseTreeComponent,
    FormControlEditComponent,
    OrderJoinModalContentComponent
  ],
  exports: [
    TreeComponent,
    PaginationComponent,
    BreadcrumbComponent,
    TableComponent,
    PromptComponent,
    LastStrPipe,
    FirStrPipe,
    FirStrTPipe,
    CuttingStrPipe,
    KeysPipe,
    SafeStrPipe,
    arrayToStrPipe,
    RichEditorDirective,
    InputToIntDirective,
    StepComponent,
    ResourceClassifyTreeComponent,
    ProductTerminalComponent,
    ProductUploadImageComponent,
    FileUploadModule,
    ReactiveFormsModule,
    FormControlComponent,
    InputTrimModule,
    CustomFormsModule,
    ProductTerminalDetailComponent,
    ResourceClassifyTreeWithDataComponent,
    ProductDetailFormItemComponent,
    ProductDetailImageComponent,
    ProductDetailFormComponent,
    ResourceTypeListComponent,
    ZsModalComponent,
    SelectionComponent,
    GatewayPavmenuTreeComponent,
    GatewayPavmenuTreeWithDataComponent,
    FormControlEditComponent,
    ModalModule,
    DragulaModule,
    TabsModule,
    TypeaheadModule, 
    OrderJoinModalContentComponent
    // UEditorModule
    // FormlyModule,
    // FormlyBootstrapModule   
  ],
  providers: [
    PromptService,
    LocalStorageService,
    BsModalService,
    PaginationService,
    ConfigService,
  ]
})
export class PublicModule {
  constructor(@Optional() @SkipSelf() parent: PublicModule) {
    if (parent) {
      throw new Error('共享模块已经加载，不能再次加载')
    }
  }
}
